//
//  XDPlaceCollectionViewCell.m
//  Le way walkers
//
//  Created by YaZhiLiang on 15/5/14.
//  Copyright (c) 2015年 LTXZ. All rights reserved.
//

#import "XDPlaceCollectionViewCell.h"

#import "UIImageView+WebCache.h"

@interface XDPlaceCollectionViewCell ()


@property (nonatomic, retain) UIImageView *pic;

@property (nonatomic ,retain) UILabel *name;

@end

@implementation XDPlaceCollectionViewCell
#warning 初始化 创建控件

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.pic = [[UIImageView alloc] init];
        
        [self.contentView addSubview:self.pic];
        
        self.name = [[UILabel alloc] init];
        
        [self.pic addSubview:self.name];
        
        [_name release];
        
        [_pic release];
        
    }
    
    return self;
}

#warning 布局信息方法
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.pic.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.bounds.size.height);
    
    self.pic.layer.cornerRadius = 8;
    
    self.pic.layer.masksToBounds = YES;
    
    self.pic.userInteractionEnabled = YES;
    
    self.name.frame = CGRectMake(10, 100, 120, 40);
    
    self.name.font = [UIFont systemFontOfSize:17.0];
    
//    self.name.backgroundColor = [UIColor blackColor];
    
    self.name.textColor = [UIColor whiteColor];
    
    self.name.userInteractionEnabled = YES;
    
}


#warning model对象setter方法 用来给控件赋值
- (void)setXdModel:(XDPlaceViewModel *)xdModel
{
    if (_xdModel != xdModel) {
        
        [_xdModel release];
        
        _xdModel = [xdModel retain];
    }
    
    //    [self.MyImage sd_setImageWithURL:(NSURL *)xdModel.cover_s placeholderImage:[UIImage imageNamed:@"1.jpg"]];
    
    [self.pic sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", xdModel.cover_s]]];
    
    NSLog(@"wangzhi%@", xdModel.cover_s);
    
    self.name.text = xdModel.name;
    
    self.typeName = xdModel.type;
    
    self.ScenicID = xdModel.ScenicID;
}


@end
